Revert "Use time crate directly to get the year"
authorEwan Higgs <ewan_higgs@yahoo.co.uk>
Wed, 29 Mar 2017 19:51:50 +0000 (21:51 +0200)
committerEwan Higgs <ewan_higgs@yahoo.co.uk>
Wed, 29 Mar 2017 19:51:50 +0000 (21:51 +0200)
This reverts commit 47221e98189daa34e47934d44223db12db84c7b9.

Cargo.lock
Cargo.toml
src/cargo/lib.rs
src/cargo/ops/cargo_new.rs
tests/new.rs

index 140f2aa2cc3ebe68a4adadd2709ff60fb0458e0f..bfce301119cba92146125c44e71d389408fb64d9 100644 (file)
@@ -5,6 +5,7 @@ dependencies = [
  "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "cargotest 0.1.0",
+ "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
  "crates-io 0.7.0",
  "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -36,7 +37,6 @@ dependencies = [
  "tar 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
  "toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -105,6 +105,15 @@ name = "cfg-if"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "chrono"
+version = "0.2.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "cmake"
 version = "0.1.20"
@@ -825,6 +834,7 @@ dependencies = [
 "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
 "checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074"
 "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c"
+"checksum chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00"
 "checksum cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "a3a6805df695087e7c1bcd9a82e03ad6fb864c8e67ac41b1348229ce5b7f0407"
 "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97"
 "checksum curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c90e1240ef340dd4027ade439e5c7c2064dd9dc652682117bd50d1486a3add7b"
index 91fcbd0dce6f655ed4b3eb46041f5a1c9fac5c7d..5e83d2e2cd179b03697953fa0d3ea4a55cbfd61f 100644 (file)
@@ -17,6 +17,7 @@ name = "cargo"
 path = "src/cargo/lib.rs"
 
 [dependencies]
+chrono = "0.2.25"
 crates-io = { path = "src/crates-io", version = "0.7" }
 crossbeam = "0.2"
 curl = "0.4.6"
@@ -43,7 +44,6 @@ shell-escape = "0.1"
 tar = { version = "0.4", default-features = false }
 tempdir = "0.3"
 term = "0.4.4"
-time = "0.1.36"
 toml = "0.3"
 url = "1.1"
 
index 736a9c04da4a89fb40b8e1984f5e38e7ae8467cb..3c27a332e16d5fbe9f0c3c766667f30726708013 100755 (executable)
@@ -5,6 +5,7 @@
 #[macro_use] extern crate log;
 #[macro_use] extern crate serde_derive;
 #[macro_use] extern crate serde_json;
+extern crate chrono;
 extern crate crates_io as registry;
 extern crate crossbeam;
 extern crate curl;
@@ -26,7 +27,6 @@ extern crate shell_escape;
 extern crate tar;
 extern crate tempdir;
 extern crate term;
-extern crate time;
 extern crate toml;
 extern crate url;
 
index 18a62c7fc4ad84917ae532497ebdd230947343f4..536b2bc50020034f9a1857da53364d861d966024 100644 (file)
@@ -8,9 +8,9 @@ use git2::Config as GitConfig;
 
 use term::color::BLACK;
 
+use chrono::{Datelike,Local};
 use handlebars::{Handlebars, no_escape};
 use tempdir::TempDir;
-use time;
 use toml;
 
 use core::Workspace;
@@ -521,6 +521,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
     let mut data = BTreeMap::new();
     data.insert("name".to_owned(), name.to_owned());
     data.insert("author".to_owned(), author);
+    data.insert("year".to_owned(), Local::now().year().to_string());
 
     let template_set = try!(get_input_template(config, opts));
     for template in template_set.template_files.iter() {
index 9f9d3ba299f0bb51b673891c85be758d31c44edb..b212ba84348a521c04c0f759ab8b9fa816e97375 100644 (file)
@@ -1,8 +1,8 @@
 extern crate cargo;
 extern crate cargotest;
+extern crate chrono;
 extern crate hamcrest;
 extern crate tempdir;
-extern crate time;
 
 use std::fs::{self, File};
 use std::io::prelude::*;
@@ -11,6 +11,7 @@ use std::env;
 use cargo::util::ProcessBuilder;
 use cargotest::process;
 use cargotest::support::{execs, git, paths};
+use chrono::{Datelike,Local};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 use tempdir::TempDir;
 
@@ -97,6 +98,11 @@ fn main () {
     assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
     assert_that(&paths::root().join("foo/src/main.rs"), existing_file());
 
+    let license = paths::root().join("foo/LICENSE");
+    let mut contents = String::new();
+    File::open(&license).unwrap().read_to_string(&mut contents).unwrap();
+    assert!(contents.contains(&format!("(c) {} {}", Local::now().year(), "foo")));
+
     assert_that(cargo_process("build").cwd(&paths::root().join("foo")),
                 execs().with_status(0));
     assert_that(&paths::root().join(&format!("foo/target/debug/foo{}",